<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('质检单')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <!--<div class="layui-inline">
                        <label class="layui-form-label">创建开始时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="cjsj_" id="test5" placeholder="yyyy-MM-dd" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">  </label>
                        <div class="layui-input-inline" style="height:20px">
                            &#45;&#45;
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">创建结束时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="cjsj" id="test6" placeholder="yyyy-MM-dd" />

                        </div>
                    </div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="gysmc" name="gysmc" placeholder="供应商名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="ASN编号"/>
                        </div>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">搜索</a>
                    </div>

                    <div class="moreSearch" style="display: none">

                        <div class="layui-inline">
                            <label class="layui-form-label">质检单号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="zjdh" name="zjdh" placeholder="质检单号"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">出库任务状态</label>
                            <select name="ckrwzt" lay-filter="aihao">
                                <option value="">全部</option>
                                <option value="0">初始</option>
                                <option value="1">任务创建</option>
                                <option value="2">部分完成</option>
                                <option value="3">全部完成</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">入库任务状态</label>
                            <select name="rkrwzt" lay-filter="aihao">
                                <option value="">全部</option>
                                <option value="0">初始</option>
                                <option value="1">任务创建</option>
                                <option value="2">部分完成</option>
                                <option value="3">全部完成</option>
                            </select>
                        </div>

                    </div>
                </form>

                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
               <!-- <div class="group-button" id="toolbar">
                    <a class="layui-btn layui-btn-sm layui-btn-normal  out-put" >
                        <i class="layui-icon">&#x1005;</i> 导出
                    </a>
                </div>-->

                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>


<div th:include="public/public_js::public_js"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script>
    $("form input[type=text]").each(function () {
        this.value = $.trim(this.value);

        $(document).ready(function () {//通用方法去输入框前后空格
            $("form").on("change", function () {
                $("form input[type=text]").each(function () {
                    this.value = $.trim(this.value);
                });
            })
        });
    });

    console.log("我来了！！ ");
    $(".moreBtn").on("click",function () {
        $(".moreSearch").toggle();
    })
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.select2({
            elem: ".js-data-example-ajax",
            url: "/wmsrrailwayplatform/list"
        });
        window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                alert(row.mc);
            },
            "click #check": function (e, value, row, index) {//查看
                checkDialog(row.id);
            },
            "click #modify": function (e, value, row, index) {//查看
                modifyDialog(row.id);
            },
            "click #fjgl": function (e, value, row, index) {//查看
                fjglDialog(row.id);
            },
            "click #zljy": function (e, value, row, index) {//查看
                zljyDialog(row.id);
            },
        };

        /*查看任务详情*/
        function checkDialog(id) {
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "查看详情",
                type: 2,
                content: "/Qualitychecklist/qualitydetails?sszjdid=" + id,
                area: ['70%', '70%'], //设置dialog大小，也可以不设置，
            });
        }
        /*附件管理*/
        function fjglDialog(id) {
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "附件管理",
                type: 2,
                content: "/Qualitychecklist/jfgl?sszjdid=" + id,
                area: ['70%', '70%'], //设置dialog大小，也可以不设置，
            });
        }
        /*质量检验*/
        function zljyDialog(id) {
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "附件管理",
                type: 2,
                content: "/Qualitychecklist/Qualitytesting?sszjdid=" + id,
                area: ['70%', '70%'], //设置dialog大小，也可以不设置，
            });
        }


        /*修改任务详情*/
        function modifyDialog(id) {
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "修改质检单",
                type: 2,
                content: "/Qualitychecklist/modify?sszjdid=" + id,
                area: ['70%', '70%'], //设置dialog大小，也可以不设置，
            });
        }

        /*顶部按钮多选启用*/
        $("#btn_qi").on('click', function () {
            var index = 0;
            var $rows = $table.bootstrapTable('getSelections');
            //判断选中的库区里是否有已经启用的
            for (var i = 0; i < $rows.length; i++) {
                if ($rows[i].jhzt == 1) {
                    index++;
                }
            }
        })

        //创建时间开始
        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff',
        });
        //创建时间结束
        laydate.render({
            elem: '#etime'
            , theme: '#20a0ff',
        });
        /*laydate.render({
            elem: '#test5'
            , theme: '#20a0ff'
        });*/
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/wmsqualityinspectionlist/list',
            columns: [
                {
                    field: '',
                    checkbox: true
                },{
                    field: 'ckmc',
                    title: '仓库名称'
                },{
                    field: 'ownerMc',
                    title: '货主名称'
                },{
                    field: 'gysmc',
                    title: '供应商'
                },{
                    field: 'zjdh',
                    title: '质检单号'
                },{
                    field: 'asnbh',
                    title: 'ASN编号'
                },{
                    field: 'cjsj',
                    title: '创建时间'
                },{
                    field: 'zjsj',
                    title: '质检时间'
                },{
                    field: 'zjr',
                    title: '质检人'
                },{
                    field: 'show_ckrwzt',
                    title: '出库任务状态'
                },{
                    field: 'show_rkrwzt',
                    title: '入库质检状态'
                },{
                    field: 'show_zt',
                    title: '质检状态'
                }, {
                    field: 'caozuo',
                    title: '操作',
                    events: operateEvent,
                    formatter: operateFormatter
                }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });

        function operateFormatter(value, row, index) {

           if (row.ckrwzt=='3'&& row.rkrwzt=='0'&& row.zt=='0'){
                return [
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="fjgl">附件管理</a>',
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="check">查看</a>',
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="zljy">质量检验</a>',
                ].join('')
            }else if(row.ckrwzt=='3'){
            return [
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="fjgl">附件管理</a>',
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="check">查看</a>',
                    '<a class="layui-btn  layui-btn-xs" id="modify">修改</a>'
                ].join('')
            }else{
                   return [
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="fjgl">附件管理</a>',
                    '<a class="layui-btn layui-btn-primary layui-btn-xs" id="check">查看</a>',
                ].join('')
            }
        }

        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
    });
</script>
</html>